﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using IDAL;

namespace DAL
{
    public class D_VipLevel : IVipLevel
    {
        WishDayEntities _e;
        public D_VipLevel()
        {
            _e = new WishDayEntities();
        }
        public void Add(VipLevel obj)
        {
            _e.VipLevel.Add(obj);
            _e.SaveChanges();
        }

        public void Delete(int id)
        {
            _e.VipLevel.Remove(_e.VipLevel.Find(id));
            _e.SaveChanges();
        }

        public VipLevel FindById(int id)
        {
            return _e.VipLevel.Find(id);
        }

        public List<VipLevel> GetAll()
        {
            return _e.VipLevel.ToList();
        }

        public void Update(int id, VipLevel obj)
        {
            var data = _e.VipLevel.Find(id);
            data.VipName = obj.VipName;
            data.VipPrice = obj.VipPrice;
            data.VipDay = obj.VipDay;
            data.VStorageNum = obj.VStorageNum;
            _e.SaveChanges();
        }
    }
}
